package com.ruoyi.space.util;

import java.util.HashMap;

/*
* 封装一个返回值
* */
public class Result extends HashMap<String, Object> {
    //无参构造,当返回结果对象,内置成功信息
    private Result(){
        super.put("code","200");
        super.put("msg","success");
    }
    //成功返回
    public static Result success(){
        return new Result();
    }
    public static Result error(String msg,int code){
        Result result=new Result();
        result.put("code",code);
        result.put("msg",msg);
        return result;
    }
    public static Result error(String msg){
        return error(msg,500);
    }
    public static Result error(){
        return error("出现了异常,检查一下原因");
    }

    public Result put(String key,Object val){
        super.put(key, val);
        return this;
    }
}
